package com.donfu.web.controller.house;

import java.util.List;

import com.donfu.system.domain.house.HouseSpecValue;
import com.donfu.system.service.house.IHouseSpecValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.donfu.common.annotation.Log;
import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.common.enums.BusinessType;
import com.donfu.common.utils.poi.ExcelUtil;
import com.donfu.common.core.page.TableDataInfo;

/**
 * 商品规格参数可选值Controller
 * 
 * @author donfu
 * @date 2021-12-06
 */
@Api(tags = "后台--商品规格参数可选值")
@RestController
@RequestMapping("/system/value")
public class HouseSpecValueController extends BaseController
{
    @Autowired
    private IHouseSpecValueService houseSpecValueService;

    /**
     * 查询商品规格参数可选值列表
     */
    @ApiOperation("查询商品规格参数可选值列表")
    @PreAuthorize("@ss.hasPermi('system:value:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseSpecValue houseSpecValue)
    {
        startPage();
        List<HouseSpecValue> list = houseSpecValueService.selectHouseSpecValueList(houseSpecValue);
        return getDataTable(list);
    }

    /**
     * 导出商品规格参数可选值列表
     */
    @ApiOperation("导出商品规格参数可选值列表")
    @PreAuthorize("@ss.hasPermi('system:value:export')")
    @Log(title = "商品规格参数可选值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HouseSpecValue houseSpecValue)
    {
        List<HouseSpecValue> list = houseSpecValueService.selectHouseSpecValueList(houseSpecValue);
        ExcelUtil<HouseSpecValue> util = new ExcelUtil<HouseSpecValue>(HouseSpecValue.class);
        return util.exportExcel(list, "商品规格参数可选值数据");
    }

    /**
     * 获取商品规格参数可选值详细信息
     */
    @ApiOperation("获取商品规格参数可选值详细信息")
    @ApiImplicitParam(name = "id", value = "商品规格参数可选值Id", dataType = "Long", required = true)
    @PreAuthorize("@ss.hasPermi('system:value:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(houseSpecValueService.selectHouseSpecValueById(id));
    }

    /**
     * 新增商品规格参数可选值
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('system:value:add')")
    @Log(title = "商品规格参数可选值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseSpecValue houseSpecValue)
    {
        return toAjax(houseSpecValueService.insertHouseSpecValue(houseSpecValue));
    }

    /**
     * 修改商品规格参数可选值
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('system:value:edit')")
    @Log(title = "商品规格参数可选值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseSpecValue houseSpecValue)
    {
        return toAjax(houseSpecValueService.updateHouseSpecValue(houseSpecValue));
    }

    /**
     * 删除商品规格参数可选值
     */
    @ApiOperation("删除")
    @ApiImplicitParam(name = "ids", value = "商品规格参数可选值Id集合", dataType = "Long", required = true)
    @PreAuthorize("@ss.hasPermi('system:value:remove')")
    @Log(title = "商品规格参数可选值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseSpecValueService.deleteHouseSpecValueByIds(ids));
    }
}
